其他
打开这份指南,数据库运维也能优雅、简单!
对于常规数据库的运维监控来说,如何能够快速简洁的发现问题,直达问题本质并解决常见问题,是 Bethune 的安身立命之本。
简约,优雅,专业,直抵本心,这是用户对 Bethune 的评价。
Bethune X 功能强大,许多特性能够很好地解决DBA日常运维中遇到的问题,本文选取几个场景,介绍如何利用 Bethune X 为你的数据库多添一道保障!
阅读提示:
Part 1:通过空间监控功能分析 AUD$ 的空间
Part 2:通过下钻功能探查数据库深层问题
Part 3:通过SQL自定义监控实现主机日志监控
SQL> select segment_name,bytes/1024/1024 MB from dba_segments where segment_name='AUD$';
SEGMENT_NAME MB
------------------------------ ----------
AUD$ 8154
SQL> truncate table sys.aud$;
Table truncated.
SQL> select segment_name,bytes/1024/1024 MB from dba_segments where segment_name='AUD$';
SEGMENT_NAME MB
------------------------------ ----------
AUD$ .0625
并且,不能在业务高峰期间进行索引创建操作,避免引发系统竞争。
SQL> select count(*) from TP_SYS_FIELDHISTORY;
COUNT(*)
----------
2430863
SQL> select count(distinct(RECORDID)) from CUST_U_ENMOTECH.TP_SYS_FIELDHISTORY;
COUNT(DISTINCT(RECORDID))
-------------------------
1944293
SQL> explain plan for delete from tp_sys_fieldhistory where recordid=:"SYS_B_0"
2 ;
Explained.
SQL> set serveroutput on
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 2894643821
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 1 | 42 | 10379 (1)| 00:02:05 |
| 1 | DELETE | TP_SYS_FIELDHISTORY | | | | |
|* 2 | TABLE ACCESS FULL| TP_SYS_FIELDHISTORY | 1 | 42 | 10379 (1)| 00:02:05 |
------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("RECORDID"=:SYS_B_0)
14 rows selected.
SQL> create index idx_tpsys_fldhist_rcd on TP_SYS_FIELDHISTORY(RECORDID) compute statistics;
Index created.
SQL> explain plan for delete from tp_sys_fieldhistory where recordid=:"SYS_B_0";
Explained.
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 3460354814
-------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 1 | 42 | 3 (0)| 00:00:01 |
| 1 | DELETE | TP_SYS_FIELDHISTORY | | | | |
|* 2 | INDEX RANGE SCAN| IDX_TPSYS_FLDHIST_RCD | 1 | 42 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("RECORDID"=:SYS_B_0)
第一步:必要的赋权
chmod 744 /var/log/secure
create or replace directory var_log as '/var/log’;
grant read,write on directory var_log to BP_QUERY;
CREATE TABLE secure_log
(
text varchar2(4000)
)
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY var_log
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
nobadfile
nodiscardfile
nologfile
)
LOCATION ('secure')
)
reject limit unlimited ;
select * from secure_log where rownum<10
grant select on secure_log to BP_QUERY;
采集任务选择Oracle,采集频率按需配置。
第四步:创建告警策略,添加到模板,使用到目标数据库
这儿我们对「TEXT 」字段进行规则配置,利用like 表达式做全模糊查询,包含这段关键字的日志都会触发该告警规则。
1.通过赋权让Oracle用户有权限读取日志的权限;
2.创建外部表,让Oracle 数据库能访问该日志;
3.在Bethune X 里面创建采集任务,并保证目标数据库的采集任务能测试成功;
4.针对这个采集任务创建个告警策略,添加到模板里面,应用到数据库上。
云和恩墨是全球化数据资产端到端解决方案提供商,致力于将数据思维带给每个组织、每个人,构建数据驱动的智能未来。我们在数据服务、运维平台、数据智能、教育培训等领域为企业和个人提供可信赖的产品、解决方案和服务,与业界厂商广泛合作,围绕用户需求,持续为客户创造价值、为行业培养人才,激发数据潜能,为成就未来数字化企业和数据人才而不懈努力。
云和恩墨坚持围绕数据时代客户面临的挑战持续创新,不断加大研发投入,持续完善贯穿业务智能、开发管控、云管平台、分布式存储和基础运维的端到端产品和服务,助力企业和个人成功。